package com.funkyfurrymonkey.engine ;

/**
 * ...
 * @author Marcos Martinez
 */
class Shuffle
{

	public var m_aCards:Array<Array<Int>>;
	
	public function new() 
	{
		
	}
	
	public static function createArray(nLength:Int, nMaxValue:Int):Array<Int>
	{
		
		var aArray:Array<Int> = new Array<Int>();
		for ( i in 0...nMaxValue)
		{
			aArray.push(i);
		}
		aArray = randomArray(aArray);
		aArray = aArray.slice(0,nLength);
		return aArray;
	}
	
	public static function randomArray(_array:Array<Int>)
	{
		var _length:Int= _array.length;
		var mixed:Array<Int>= _array.slice(0,_length);
		var rn:Int;
		var it:Int;
		var el:Int;
		for (i in 0..._array.length)
		{
			el = mixed[i];
			rn = Math.floor(Math.random() * _length);
			mixed[i] = mixed[rn];
			mixed[rn] = el;
		}
		return mixed;
	}
}